package com.system.core.plugins.mybatis.custom;

import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
import org.mybatis.generator.api.dom.java.JavaVisibility;
import org.mybatis.generator.api.dom.java.Method;
import org.mybatis.generator.api.dom.java.Parameter;

import lombok.experimental.UtilityClass;

@UtilityClass
public class MyUpdateInterface {

	public Method updateBatchByPrimaryKeySelectiveMethod(IntrospectedTable introspectedTable) {
		Method batchUpdate = new Method("updateBatchByPrimaryKeySelective");
		Parameter batchUpdateParam = new Parameter(
				new FullyQualifiedJavaType("List<"+introspectedTable.getBaseRecordType()+">"),"list");
		batchUpdate.addParameter(batchUpdateParam);
		batchUpdate.setVisibility(JavaVisibility.PUBLIC);
		batchUpdate.addJavaDocLine("/**");
		batchUpdate.addJavaDocLine(" * @mbg.generated");
		batchUpdate.addJavaDocLine(" * 批量更新");
		batchUpdate.addJavaDocLine(" */");
		batchUpdate.setAbstract(true);
		batchUpdate.setReturnType(new FullyQualifiedJavaType("int"));
		return batchUpdate;
	}
	
	public Method updateBatchByPrimaryKeyMethod(IntrospectedTable introspectedTable) {
		Method batchUpdate2 = new Method("updateBatchByPrimaryKey");
		Parameter batchUpdateParam = new Parameter(
				new FullyQualifiedJavaType("List<"+introspectedTable.getBaseRecordType()+">"),"list");
		batchUpdate2.addParameter(batchUpdateParam);
		batchUpdate2.setVisibility(JavaVisibility.PUBLIC);
		batchUpdate2.addJavaDocLine("/**");
		batchUpdate2.addJavaDocLine(" * @mbg.generated");
		batchUpdate2.addJavaDocLine(" * 批量更新");
		batchUpdate2.addJavaDocLine(" */");
		batchUpdate2.setAbstract(true);
		batchUpdate2.setReturnType(new FullyQualifiedJavaType("int"));
		return batchUpdate2;
	}
}
